using System;
using System.Collections.Generic;
using System.Text;

using XGAE.Framework;

namespace XGAE.Body.Motion
{
    /// <summary>
    /// Wrapper class that implements all of the glue-code to get the module working.
    /// </summary>
    class MotionManager : MotionModule
    {
        #region C'tors

        public MotionManager()
            : base()
        {
        }

        #endregion

        #region Persistence & Interface Management

	    /// <summary>
        /// Return a new interface of a given type.
	    /// </summary>
	    /// <param name="name"></param>
	    /// <returns></returns>
        public Interface Export(string name)
        {
            if (name == "Relative")
            {
                Interface i = new MotionRelative(this) as Interface;
                return i;
            }
            if (name == "Parameters")
            {
                Interface i = new MotionParameters(this) as Interface;
                return i;
            }

            //Warning("Component " + m_type + " does not export interface '" + name + "'.", __FILE__, __LINE__);
            return null;
        }

	    /// <summary>
        /// Store dependencies for convenience, as passed by the architecture.
        /// Find a matching interface, and store the reference for later use. 
	    /// </summary>
	    /// <param name="name"></param>
	    /// <param name="i"></param>
	    /// <returns></returns>
        public bool Import(string name, Interface i)
        {
            if (name == "backend"  &&  Interface.IsCompatible(i.Version, 0x0002))
	        {
                this.Backend = i as Backend.IMotion;
                if (this.Backend != null) return true;
            }
         
            //Warning( "Component " + m_type + " cannot import interface '" + name + "'.", __FILE__, __LINE__ );
            return false;
        }

        #endregion
    }
}
